<extend name="admin/main"/>

<block name="title">
    <title>编辑产品</title>
</block>

<block name="css">
    <link type="text/css" href="__PUBLIC__/assets/plugins/form-pagedown/css/jquery.pagedown-bootstrap.css"
          rel="stylesheet">
</block>

<block name="heading">编辑产品</block>

<block name="content">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <p>Edit Product {$product['title']}</p>
        </div>
        <div class="panel-body">
            <form action="/admin/product/update" enctype="multipart/form-data" method="post">
                <input class="hidden" type="hidden" name="id" value="{$product['id']}">
                <div class="form-group">
                    <label for="category">分类</label>
                    <select id="category" name="product_categories_id" class="form-control" required>
                        <foreach name="categories" item="category">
                            <?php $selected = $product['product_categories_id'] == $category['id'] ? 'selected' : '' ?>
                            <option value="{$category.id}" {$selected}>{$category.title}</option>
                        </foreach>
                    </select>
                </div>
                <div class="form-group">
                    <label for="title">title</label>
                    <input type="text" class="form-control" name="title" id="title" required value="{$product.title}">
                </div>
                <div class="form-group">
                    <label for="icon">icon</label>
                    <input type="file" class="form-control" name="icon" id="icon">
                </div>
                <div class="form-group">
                    <label for="banner">banner</label>
                    <input type="file" class="form-control" name="banner" id="banner">
                </div>
                <div class="form-group">
                    <label for="description">description</label>
                    <input type="text" class="form-control" name="description" id="description" required value="{$product.description}">
                </div>
                <div class="form-group">
                    <label for="content">content</label>
                    <textarea id="content" name="content" required >{$product.content}</textarea>
                </div>
                <div class="form-group">
                    <input type="submit" value="提交" class="btn btn-success">
                </div>
            </form>
        </div>
    </div>
</block>

<block name="js">
    <script type="text/javascript" src="__PUBLIC__/assets/demo/demo.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/demo/demo-switcher.js"></script>
    <script type="text/javascript" src="__PUBLIC__/assets/plugins/bootbox/bootbox.js"></script>
    <script src="__PUBLIC__/assets/plugins/form-pagedown/js/jquery.pagedown-bootstrap.combined.js"></script>
    <script>
        $(document).ready(function () {
            $("textarea#content").pagedownBootstrap();
            $('.wmd-preview').addClass('well');
        });
    </script>
</block>
